Build a Governance Bot

What

This bounty was sponsered by Boardroom, a platform for governance participation, and required a developer to use the Boardroom read-only API to build a chat bot for a popular platform. So, I have chosen an unpopular platform in Matrix. gg.

The bot

One of the most important things to add, in my opinion, was automatic updates in the room. The updates I implemented were for new proposals on a given protocol. The bot will:

  1. reach out to the /protocols/<protocol-name>/proposals endpoint
  2. filter the list to get only un-seen proposals
  3. print the new proposals into the room

Users in the room are also able to request information about the latest proposals for any protocol, get details about a specific protocol, and check the voting history of any wallet or ENS address.

The technologies

The following tools were used:

The bot is written in Javascript and runs on Nodejs 16+. It has a very simple routine, using the open source matrix-bot-sdk, to sync with a HomeServer on a regular basis. Commands all live in their own folders and use a special handler to load them. I followed a structure similar to Fastify plugins so that commands could very easily be added. A simple command would look like this:

const { RichReply } = require('matrix-bot-sdk')

async function handler (params, context) {
const { roomId, event } = context

const reply = RichReply.createFor(roomId, event, 'Hello to you', '<b>Hello</b> to you')
reply.msgtype = 'm.notice'

return reply
}

module.exports = {
command: '!hello',
handler
}

This structure gives the developer a lot of flexibility to create a reply but abstracts away the knowledge to send the reply and gives the centralized control over how to send. There is also an easy way to declare what the required command is.

Roadmap

I think this bot could be quite useful in the future but still has a few rough edges. Below are a few things I am looking to solve before packaging this project up: